<?php
require_once("BaseUser.php");
require_once("MysqlConn.php");
require_once("../util/SessionManager.php");
require_once("../util/XConstants.php");

class Manager extends BaseUser {
   public function login() {
      $name = $this->id;
      $pass = $this->pwd;
      $query = "select * from Managers" .
         " where MAN_ID='$name' and MAN_PWD='$pass'";
      $conn = new MysqlConn();
      $conn->query($query);
      $r = $conn->next();

      if(empty($r)) {
         return XConstants::$LOGIN_FAILD;
      }
      else {
         $this->id = $r["MAN_ID"];
         $this->pwd = $r["MAN_PWD"];
         $session = new SessionManager();
         $session->setUser($this->id);
      }

      return XConstants::$LOGIN_SUCCESS;
   }
}
?>